const House = require('../database/House')

// 渲染
const list = async (req, res) => {
  let result = await House.getHouseList()
  // console.log(result);
  res.json({
    result,
  })
}



// 添加
const create = async (req, res) => {
  //校验数据 req.body.title
  let data = [req.body.title,
  req.body.description,
  req.body.price,
  req.body.area,
  req.body.bedrooms,
  req.body.bathrooms,
  req.body.address,
  req.body.city,
  req.body.state,
  req.body.zip_code,
  req.body.country,
  req.body.latitude,
  req.body.longitude,
  req.body.construction_year,
  req.body.property_type,
  req.body.ownership,
  req.body.amenities,
  req.body.status,]
  let result = await House.createHouse(data)
  res.json({
    result,
  })
}



// 删除
const delectlist = async (req, res) => {
  // let dataid = req
  // console.log(dat)
  // let data = 5
  let result = await House.getdelect(req)
  res.json({
    result,
  })
}



// 修改
const getxg = async (req, res) => {
  let result = await House.getxiugai(req)
  res.json({
    result,
  })
}



// 搜索
const getss = async (req, res) => {
  // let data = req.query
  let result = await House.getsous(req)
  res.json({
    result,
  })
}


module.exports = {
  list,
  create,
  delectlist,
  getxg,
  getss
}
